﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZG_member.Model;
using ZG_member.BLL;
using System.Configuration;
namespace ZG_member
{
    public partial class duanxinshezhi : Form
    {
        public duanxinshezhi()
        {
            InitializeComponent();
            skinEngine1.SkinFile = Application.StartupPath + ConfigurationManager.AppSettings["Skin"];
            this.Opacity = 0;
        }
        BLL.SMS sbll = new BLL.SMS();
        Model.Duanxingneirong dxmodle = new Model.Duanxingneirong();
        private void duanxinshezhi_Load(object sender, EventArgs e)
        {
            MessageBox.Show("对不起，您未开通此功能");
            this.Close();
            
            this.timer1.Start();
            this.label4.ForeColor = System.Drawing.Color.Red;
            this.label5.ForeColor = System.Drawing.Color.Red;
            this.label12.ForeColor = System.Drawing.Color.Red;
            this.label11.ForeColor = System.Drawing.Color.Red;
            this.label13.ForeColor = System.Drawing.Color.Red;

                Model.SMS smsmodle = sbll.GetListmodel();
                this.txthuixinsongjifen.Text = smsmodle.SMSjifen1;
                string[] asdqwe = smsmodle.SMSneirong1.Split('#');
                string neirong = asdqwe[0];
                this.txthuixinneirong.Text = neirong;
                dxmodle = dbll.getmodel(1);
                //string[] faka = dxmodle.Fasongneirong.Split('#');
                this.txtfaka.Text = dxmodle.Fasongneirong;
                dxmodle = dbll.getmodel(2);
                //string[] huixin = dxmodle.Fasongneirong.Split('#');
                this.txthuixin.Text = dxmodle.Fasongneirong;
                dxmodle = dbll.getmodel(3);
                //string[] shengji = dxmodle.Fasongneirong.Split('#');
                this.txtshengji.Text = dxmodle.Fasongneirong;
                dxmodle = dbll.getmodel(4);
                //string[] jifen = dxmodle.Fasongneirong.Split('#');
                this.txtjifen.Text = dxmodle.Fasongneirong;
            
            
           
        }

        

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Left += 2;
            this.Opacity += 0.1;
            if (Opacity == 1)
            {
                this.timer1.Stop();

            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            this.Top = this.Top + 10;
            this.Opacity = this.Opacity - 0.06;
            if (Opacity <= 0)
            {
                this.timer2.Stop();
                this.Close();
            }
        }

        int flag = 0;

        private void duanxinshezhi_FormClosing(object sender, FormClosingEventArgs e)
        {
            //if (flag == 0)
            //{
            //    e.Cancel = true;
            //    flag = 1;
            //    this.timer2.Start();
            //}
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!(((e.KeyChar >= '0') && (e.KeyChar <= '9')) || e.KeyChar <= 31))
            {
                //if (e.KeyChar == '.')
                //{
                //    if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
                //        e.Handled = true;
                //}
                //else
                e.Handled = true;
            }
            else
            {
                if (e.KeyChar <= 31)
                {
                    e.Handled = false;
                }
                else if (((TextBox)sender).Text.Trim().IndexOf('.') > -1)
                {
                    if (((TextBox)sender).Text.Trim().Substring(((TextBox)sender).Text.Trim().IndexOf('.') + 1).Length >= 4)
                        e.Handled = true;
                }
            }
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            Model.SMS smsmodle = new Model.SMS();
            string duanxinneirong = this.txthuixinneirong.Text;
            duanxinneirong += "#";
            duanxinneirong += this.label4.Text;
            duanxinneirong += this.label5.Text;

            smsmodle.SMSjifen1 = this.txthuixinsongjifen.Text;
            smsmodle.SMSneirong1 = duanxinneirong;

            if (sbll.update(smsmodle))
            {
                MessageBox.Show("保存成功!");
            }
            else
            {
                MessageBox.Show("保存失败!");
            }
            this.Close();
        
        }
        BLL.Duanxingneirong dbll = new BLL.Duanxingneirong();
        private void btnfaka_Click(object sender, EventArgs e)
        {
            //this.txtfaka.Text += "#【国金黄金】";
            dbll.update(1, this.txtfaka.Text);
        }

        private void btnhuixin_Click(object sender, EventArgs e)
        {
            //this.txthuixin.Text += "#【国金黄金】";
            dbll.update(2, this.txthuixin.Text);
        }

        private void btnjifenhuanli_Click(object sender, EventArgs e)
        {
            //this.txtjifen.Text += "#【国金黄金】";
            dbll.update(4, this.txtjifen.Text);
        }

        private void btnshengji_Click(object sender, EventArgs e)
        {
            //this.txtshengji.Text += "#【国金黄金】";
            dbll.update(3, this.txtshengji.Text);
        }

        
    }
}
